import pytesseract
from PIL import Image
from PIL import ImageGrab
import pyperclip

if __name__ == '__main__':
    while True:
        im = ImageGrab.grabclipboard()
        if isinstance(im, Image.Image):
            pytesseract.pytesseract.tesseract_cmd = 'E:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
            text = pytesseract.image_to_string(im, lang='chi_sim')
            # if text:
            #     text = "".join(text.split(" "))
            print(text)
            pyperclip.copy(text)

